<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="../js/jquery.min.js"></script>
        <script src="https://cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
        <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css">
    </head>
    <body>
        <div class="container">
            <h1 class="text-center">微信二维码生成</h1>
            <div class="row">
                <div class="col-md-7">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <h4>选择方式：</h4>
                                <select class="form-control" name='type' id='type'>
                                    <option value="1">临时</option>
                                    <option value="2">永久</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <h4>推广ID：</h4>
                                <input name='scene_id' type="text" class="form-control">
                            </div>
                        </div>
                        <div class="col-md-12">
                            <button type="button" class="btn btn-default" id='do_qrcode'>生成二维码</button>
                        </div>
                    </div>
                </div>
                <div class="col-md-5">
                    <h4>二维码图片：</h4>
                    <p>
                        <img id="qrcode" src="../img/download.png" class="img-thumbnail" width="255px"></img>
                    </p>
                </div>
            </div>
        </div>
        <script>
            $('#do_qrcode').on('click',function(){
                var type = $('#type').val()
                var scene_id = $('input[name=scene_id]').val()
                $.ajax({
                    url:"../qrcode.php",
                    type:'post',
                    dataType:'json',
                    data:{
                        type:type,
                        scene_id:scene_id
                    },
                    success:function(res){
                        $('#qrcode').attr('src', res.url);
                    }
                })
            })
        </script>
        
    </body>
</html>
